define(function (require) {

    var HOST = "guozhuoqiang.top:8443/mrcourse";
    var HTTPS_ADDRESS = "https://" + HOST;
    var WSS_ADDRESS = "wss://" + HOST + "/websocket";

    return {
        login: HTTPS_ADDRESS + "/login",
        register: HTTPS_ADDRESS + "/register",
        logout: HTTPS_ADDRESS + "/logout",

        //common
        getUserInfo: match(HTTPS_ADDRESS + "/common/user/${userId}"),
        updateUserInfo: match(HTTPS_ADDRESS + "/common/user"),
        getCourse: match(HTTPS_ADDRESS + "/common/course/${courseId}"),
        getAllCourse: HTTPS_ADDRESS + "/common/course",
        getCourseFile: match(HTTPS_ADDRESS + "/common/file/${courseId}"),
        uploadCourseFile: match(HTTPS_ADDRESS + "/common/file/${courseId}"),
        downloadCourseFile: match("https://guozhuoqiang.top:8443/${path}"),
        getNotice: match(HTTPS_ADDRESS + "/common/notice/${courseId}"),
        // teacher
        createCourse: HTTPS_ADDRESS + "/teacher/course",
        updateCourse: match(HTTPS_ADDRESS + "/teacher/course/${courseId}"),
        uploadNotice: match(HTTPS_ADDRESS + "/teacher/notice/${courseId}"),
        deleteNotice: match(HTTPS_ADDRESS + "/teacher/notice/delete/${noticeId}"),
        getCourseMember: match(HTTPS_ADDRESS + "/teacher/member/${courseId}"),
        deleteCourseMember: match(HTTPS_ADDRESS + "/teacher/member/delete/${courseId}/${studentId}"),
        startCourse: match(HTTPS_ADDRESS + "/teacher/course/start/${courseId}"),
        endCourse: match(HTTPS_ADDRESS + "/teacher/course/end/${courseId}"),
        startLive: match(HTTPS_ADDRESS + "/teacher/course/start/live/${courseId}"),
        endLive: match(HTTPS_ADDRESS + "/teacher/course/end/live/${courseId}"),
        startChat: match(HTTPS_ADDRESS + "/teacher/course/start/chat/${courseId}"),
        endChat: match(HTTPS_ADDRESS + "/teacher/course/end/chat/${courseId}"),
        startVote: match(HTTPS_ADDRESS + "/teacher/course/upload/question/${courseId}"),
        endVote: match(HTTPS_ADDRESS + "/teacher/course/delete/question/${questionId}"),
        teacherGetVoteList: match(HTTPS_ADDRESS + "/teacher/question/${courseId}"),
        getCheckedCourseMember: match(HTTPS_ADDRESS + "/teacher/checkIn/students/${courseId}"),
        // student
        searchCourse: match(HTTPS_ADDRESS + "/student/search/${keyWord}"),
        searchAllCourse: HTTPS_ADDRESS + "/student/course/all",
        joinCourse: match(HTTPS_ADDRESS + "/student/course/join/${courseId}"),
        quitCourse: match(HTTPS_ADDRESS + "/student/course/quit/${courseId}"),
        checkIn: match(HTTPS_ADDRESS + "/student/checkIn/${courseId}"),
        studentGetVoteList: match(HTTPS_ADDRESS + "/student/question/${courseId}"),
        answerQuestion: match(HTTPS_ADDRESS + "/student/answer/${questionId}"),
        // websocket
        webSocketServer: match(WSS_ADDRESS + "?room=${courseId}")
    }


    // curry参数模板替换
    function match(s) {
        var reg = /\${[^}]+}/;

        function __match() {
            var args = [].slice.call(arguments);
            var __s = s;
            for (var arg in args) {
                __s = __s.replace(reg, args[arg]);
            }
            function _match() {
                var _s = __s;
                for (var arg in arguments) {
                    _s = _s.replace(reg, arguments[arg]);
                }
                if (reg.test(_s)) {
                    return __match.apply(null, args.concat([].slice.call(arguments)));
                } else {
                    return _s;
                }
            }

            _match.valueOf = function () {
                return __s;
            }
            return _match;
        }

        return __match.apply(null, Array.prototype.slice.call(arguments, 1));
    }
})